package com.tky.leave.ui.fragment;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.tky.leave.R;
import com.tky.leave.ui.AuditDetailsActivity;
import com.tky.leave.ui.WriteActivity;
import com.tky.leave.utils.OkUtils;
import com.zhy.http.okhttp.callback.StringCallback;

/**
 * Created by WX on 2016/5/10.
 * 我审批的
 * 未审核 蓝色 1
 * 审核中 黄色 2
 * 已通过 绿色 3
 * 未通过 红色 4
 */
public class AuditFragment extends Fragment {

    private View parentView;
    private ListView fragment_audit_lv;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        parentView = inflater.inflate(R.layout.fragment_audit, container, false);

        fragment_audit_lv = (ListView) parentView.findViewById(R.id.fragment_audit_lv);

        parentView.findViewById(R.id.item_audit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), AuditDetailsActivity.class));
            }
        });

//        init();
        return parentView;
    }

    public void init() {
        getData();
        fragment_audit_lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                final BurstBean.Projects bean = (BurstBean.Projects) parent.getAdapter().getItem(position);
            }
        });
    }

    public void getData() {
        getProgress(getContext(), "加载中…");

        OkUtils.get("", new StringCallback() {
            @Override
            public void onError(com.squareup.okhttp.Request request, Exception e) {

            }

            @Override
            public void onResponse(String s) {

//                BurstBean bean = new Gson().fromJson(s, BurstBean.class);
//                List<BurstBean.Projects> list = bean.getProjects();
//                fragment_burst_lv.setAdapter(new BurstAdapter(getActivity(), list));

                dismissProgress();

            }
        });
    }

    private ProgressDialog pd; // 等待提示框

    public void getProgress(Context context, String string) {
        pd = ProgressDialog.show(context, null, string, false, true);
    }

    public void dismissProgress() {
        pd.dismiss();
    }

}
